//
//  DetailsController.m
//  iphone-graph
//
//  Created by yuzhuo on 2016/12/29.
//  Copyright © 2016年 yzapp. All rights reserved.
//

#import "DetailsController.h"
#import "Constant.h"

@interface DetailsController ()

@end

@implementation DetailsController

-(instancetype) init
{
    self = [super init];
    if(self){
        [self initSubViews];
    }
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"详情";
}

-(void)initSubViews{
    [self topBg];
    [self centerSelfInfo];
    [self centerContent];
    [self bottomCollect];
    [self bottomPrase];
}

-(void)topBg{
    UIImageView *topImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150)];
    topImage.image = [UIImage imageNamed:@"noLogin_renwu"];
    [self.view addSubview:topImage];
}

-(void)centerSelfInfo{
    UIFont *font_18 = [UIFont systemFontOfSize:18];
    UIFont *font_14 = [UIFont systemFontOfSize:14];
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 180, 75, font_18.lineHeight)];
    titleLabel.font = font_18;
    titleLabel.textColor = [UIColor colorWithHexString:@"#4A4A4A"];
    titleLabel.text = @"傻颖弟";
    UILabel *job = [[UILabel alloc]initWithFrame:CGRectMake(90, 180+(font_18.lineHeight-font_14.lineHeight)/2, 100, font_14.lineHeight)];
    job.font = font_14;
    job.textColor = [UIColor colorWithHexString:@"#888888"];
    job.text = @"逗逼逼";
    
    UIImageView *avatar = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-15-60, 165, 50, 50)];
    [avatar.layer setCornerRadius:25];
    [avatar setContentMode:UIViewContentModeScaleAspectFill];
    avatar.clipsToBounds = YES;
    avatar.image = [UIImage imageNamed:@"default_parents"];
    
    [self.view addSubview:titleLabel];
    
    [self.view addSubview:job];
    [self.view addSubview:avatar];
}

-(void) centerContent{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(15, 230, SCREEN_WIDTH-30, 100)];
    label.numberOfLines = 0;
    
    label.lineBreakMode = NSLineBreakByWordWrapping;

    label.text = @"本店于十一期间特推出一系列优惠，限时限量敬请选购！沙发：钻石品质，首领风范！床垫：华贵典雅，彰显时尚！尊贵而不失奢华，典雅却不失自然！温馨和浪漫的生活，我们与你一同创造！";

    CGSize size = [label sizeThatFits:CGSizeMake(label.frame.size.width, MAXFLOAT)];

    label.frame =CGRectMake(15, 230, SCREEN_WIDTH-30, size.height);
    label.textColor = [UIColor colorWithHexString:@"#4A4A4A"];
    label.font = [UIFont systemFontOfSize:16];
    
    UIFont *font_16 = [UIFont systemFontOfSize:16];
    UILabel *morelabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 250+size.height, SCREEN_WIDTH-30, font_16.lineHeight)];
    morelabel.textColor = [UIColor colorWithHexString:@"#888888"];
    morelabel.text = @"更多分享";
    
    UIImageView *img1 = [[UIImageView alloc]initWithFrame:CGRectMake(15, 250+size.height+font_16.lineHeight+20, (SCREEN_WIDTH-50)/3, (SCREEN_WIDTH-50)/3)];
    [img1 setContentMode:UIViewContentModeScaleAspectFill];
    img1.clipsToBounds = YES;
    img1.image = [UIImage imageNamed:@"bgVote"];
    
    UIImageView *img2 = [[UIImageView alloc]initWithFrame:CGRectMake(25+(SCREEN_WIDTH-50)/3, 250+size.height+font_16.lineHeight+20, (SCREEN_WIDTH-50)/3, (SCREEN_WIDTH-50)/3)];
    [img2 setContentMode:UIViewContentModeScaleAspectFill];
    img2.clipsToBounds = YES;
    img2.image = [UIImage imageNamed:@"bgVote"];
    
    UIImageView *img3 = [[UIImageView alloc]initWithFrame:CGRectMake(35+2*(SCREEN_WIDTH-50)/3, 250+size.height+font_16.lineHeight+20, (SCREEN_WIDTH-50)/3, (SCREEN_WIDTH-50)/3)];
    [img3 setContentMode:UIViewContentModeScaleAspectFill];
    img3.clipsToBounds = YES;
    img3.image = [UIImage imageNamed:@"bgVote"];
    
    [self.view addSubview:label];
    [self.view addSubview:morelabel];
    [self.view addSubview:img1];
    [self.view addSubview:img2];
    [self.view addSubview:img3];
}

-(void)bottomCollect{
    UIFont *font_12 = [UIFont systemFontOfSize:12];
    
    UIImageView *collectImage = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/4-40, SCREEN_HEIGHT-109, 30, 30)];
    collectImage.image = [UIImage imageNamed:@"icon_collected"];
    
    UILabel *content = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/4+5, SCREEN_HEIGHT-109+15-font_12.lineHeight/2, 35, font_12.lineHeight)];
    content.textColor = [UIColor lightGrayColor];
    content.textColor = [UIColor colorWithHexString:@"#4A4A4A"];
    content.text = @"1313";
    content.font = font_12;
    [self.view addSubview:collectImage];
    [self.view addSubview:content];
}

-(void)bottomPrase{
    UIFont *font_12 = [UIFont systemFontOfSize:12];
    
    UIImageView *praseImage = [[UIImageView alloc] initWithFrame:CGRectMake(3*SCREEN_WIDTH/4-40, SCREEN_HEIGHT-109, 30, 30)];
    praseImage.image = [UIImage imageNamed:@"icon_prased"];
    
    UILabel *content = [[UILabel alloc] initWithFrame:CGRectMake(3*SCREEN_WIDTH/4+5, SCREEN_HEIGHT-109+15-font_12.lineHeight/2, 35, font_12.lineHeight)];
    content.textColor = [UIColor lightGrayColor];
    content.textColor = [UIColor colorWithHexString:@"#4A4A4A"];
    content.text = @"1313";
    content.font = font_12;
    [self.view addSubview:praseImage];
    [self.view addSubview:content];
}

@end
